<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let o = {
        age: '17',
      }
      o.age = -18
      console.log(o.age)

      let getset = (function () {
        let age = 0
        return {
          setAge: function (value) {
            if (value < 0 || value > 120) {
              console.log('超出范围')
              age = 0
            } else {
              age = value
            }
          },
          getAge: function () {
            return age
          },
        }
      })()

      getset.setAge(10)
      console.log(getset.getAge())
      getset.setAge(-10)
      console.log(getset.getAge())
    </script>
  </body>
</html>
